package com.fox.matrix;

public class Coordinate {
    private double latitude;
    private double longitude;
    private String address;

    public Coordinate(double latitude, double longitude) {
        this.latitude = latitude;
        this.longitude = longitude;
    }

    public Coordinate(double latitude, double longitude, String address) {
        this.latitude = latitude;
        this.longitude = longitude;
        this.address = address;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }


    public double getLatitude() {
        return latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public void setLongitude(double doubleitude) {
        this.longitude = doubleitude;
    }

    public double getLongitude() {
        return longitude;
    }

    @Override
    public String toString() {
        return String.format("%f,%f", latitude, longitude);
    }

    //重写equals方法经纬度相同则相等
    @Override
    public boolean equals(Object obj) {
        if (obj instanceof Coordinate) {
            Coordinate c = (Coordinate) obj;
            return c.toString().equals(this.toString());
        }
        return super.equals(obj);
    }

    //按照约定重写hashcode
    @Override
    public int hashCode() {
        return this.toString().hashCode();
    }
}
